package com.fancy.learncenter.ui.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.fancy.learncenter.R;
import com.fancy.learncenter.bean.ShowVideoOrAudioDataBean;
import com.fancy.learncenter.common.Constant;
import com.fancy.learncenter.ui.activity.PlayAudioActivity;
import com.fancy.learncenter.ui.adapter.base.CommonRecycleViewAdapter;
import com.fancy.learncenter.ui.adapter.base.CustomViewHold;
import com.fancy.learncenter.utils.Utils;

import java.util.List;

/**
 * Created by Hyy on 2016/12/28.
 */

public class FragmentShowAudioAdapter extends CommonRecycleViewAdapter<ShowVideoOrAudioDataBean.RecommendListBean> {

    Context mContext;

    public FragmentShowAudioAdapter(Context mContext, List<ShowVideoOrAudioDataBean.RecommendListBean> itemDatas) {
        super(mContext, R.layout.fragment_show_audio_item, itemDatas);

        this.mContext = mContext;
    }

    @Override
    public void bindView(CustomViewHold customViewHold, final ShowVideoOrAudioDataBean.RecommendListBean item, int position) {
        SimpleDraweeView simpleDraweeView = customViewHold.getView(R.id.simpleDraweeView);
        simpleDraweeView.setImageURI(Utils.getPicPath(item.getWholeShowResourceCoverImg(), 150, 150));
//        simpleDraweeView.setImageURI(item.getWholeShowResourceCoverImg());

        TextView title = customViewHold.getView(R.id.title);
        title.setText(item.getShowResourceName());

        TextView see = customViewHold.getView(R.id.see);
        see.setText(item.getPraise() + "人点赞");


        simpleDraweeView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(mContext, PlayAudioActivity.class);
                intent.putExtra(Constant.showResourceCoverImg, item.getWholeShowResourceCoverImg());
                intent.putExtra(Constant.playLink, item.getWholePlayLink());
                intent.putExtra(Constant.showResourceId, item.getShowResourceId());
                intent.putExtra(Constant.showResourceName, item.getShowResourceName());
                mContext.startActivity(intent);
            }
        });
    }
}
